package org.example.sys_weapons.mapper;

import org.example.sys_weapons.pojo.EntitiesDto;
import org.example.sys_weapons.pojo.GoldenDescendantDto;

import java.util.*;

public class InitData {

    /**生成随机的实体名称*/
    private static ArrayList<String> GetEntities() {
        ArrayList<String> entities = new ArrayList<>();
        for (String s : GOLDEN_DESCENDANT_DATA.ENTITIES_NAME) {

            String uuid = UUID.randomUUID().toString();
            // System.out.println(uuid);
            String name = s  +"-"+ uuid.substring(0, 7);
            entities.add(name);
        }
        return entities;
    }

    /**
     * 生成随机的实体随机数
     * @param min 最小值
     * @param max 最大值
     * @param number 数量
     * */

    private static Set<Integer> GetRandom(int min, int max, int number) {
        Random random = new Random();

        TreeSet<Integer> integers = new TreeSet<>();
        while (integers.size() != number) {
            int i = random.nextInt(max) + min;
            integers.add(i);
        }
        return integers;
    }

    /**获取初始实体*/
    public static ArrayList<EntitiesDto> getEntities() {
        Integer[] EntitiesDtoRandom = GetRandom(1, 100, GOLDEN_DESCENDANT_DATA.ENTITIES_NUMBER).toArray(new Integer[GOLDEN_DESCENDANT_DATA.ENTITIES_NUMBER]);
        Integer[] GoldenDescendantDtoRandom = GetRandom(150, 1000, GOLDEN_DESCENDANT_DATA.ENTITIES_NUMBER).toArray(new Integer[GOLDEN_DESCENDANT_DATA.ENTITIES_NUMBER]);
        ArrayList<String> entitiesName = GetEntities();

        ArrayList<EntitiesDto> entities = new ArrayList<>();
        for (int i = 0; i < GOLDEN_DESCENDANT_DATA.ENTITIES_NUMBER; i++) {

            entities.add(
                    new EntitiesDto(
                            entitiesName.get(i),
                            new GoldenDescendantDto(
                                    entitiesName.get(i),
                                    GOLDEN_DESCENDANT_DATA.GOLDEN_DESCENDANT_NAME[i],
                                    GOLDEN_DESCENDANT_DATA.GOLDEN_DESCENDANT_DESCRIPTION[i],
                                    GOLDEN_DESCENDANT_DATA.GOLDEN_DESCENDANT_KINDLING[i],
                                    GOLDEN_DESCENDANT_DATA.GOLDEN_DESCENDANT_KINDLING_DESCRIPTION[i],
                                    GOLDEN_DESCENDANT_DATA.GOLDEN_DESCENDANT_THEOCRATIC[i],
                                    GoldenDescendantDtoRandom[i]
                            ),
                            EntitiesDtoRandom[i]
                    )
            );
        }
        return entities;
    }

}
